<?php

/** @var \Laravel\Lumen\Routing\Router $router */

/*
|--------------------------------------------------------------------------
| Application Routes
|--------------------------------------------------------------------------
|
| Here is where you can register all of the routes for an application.
| It is a breeze. Simply tell Lumen the URIs it should respond to
| and give it the Closure to call when that URI is requested.
|
*/

//首页
$router->get('/', 'HomeController@index');

//分类列表
$router->get('/category/{alias}', 'HomeController@category');

//标签列表
$router->get('/tag/{tag}', 'HomeController@tag');

//归档列表
$router->get('/{year:\d{4}}/{month:\d{2}}', 'HomeController@archive');

//查看文章
$router->get('/{year:\d{4}}/{month:\d{2}}/{id:\d+}.html', 'HomeController@show');

//发表评论
$router->post('/comment', 'HomeController@comment');

//robots.txt
$router->get('/robots.txt', 'HomeController@robots');

//sitemap.xml
$router->get('/sitemap.xml', 'HomeController@sitemap');


$router->group(['prefix' => '/admin'], function () use ($router) {

    $router->get('/', function () {
        return redirect('/admin/index');
    });

    //后台登录
    $router->get('/login', 'Admin\IndexController@login');
    $router->post('/login', 'Admin\IndexController@login');

    //退出登录
    $router->get('/logout', 'Admin\IndexController@logout');

    $router->group(['middleware' => 'auth'], function () use ($router) {

        //后台框架页
        $router->get('/index', 'Admin\IndexController@index');

        //后台统计页
        $router->get('/main', 'Admin\IndexController@main');

        //修改密码
        $router->get('/password', 'Admin\IndexController@password');
        $router->post('/password', 'Admin\IndexController@password');

        //参数设置
        $router->get('/setting', 'Admin\IndexController@setting');
        $router->post('/setting', 'Admin\IndexController@setting');

        //CKFinder
        $router->get('/ckfinder', 'Admin\IndexController@ckfinder');
        $router->post('/ckfinder', 'Admin\IndexController@ckfinder');

        //友情链接
        $router->get('/link', 'Admin\LinkController@index');
        $router->get('/link/list', 'Admin\LinkController@list');
        $router->get('/link/add', 'Admin\LinkController@add');
        $router->post('/link/add', 'Admin\LinkController@add');
        $router->get('/link/edit', 'Admin\LinkController@edit');
        $router->post('/link/edit', 'Admin\LinkController@edit');
        $router->post('/link/del', 'Admin\LinkController@del');

        //分类管理
        $router->get('/category', 'Admin\CategoryController@index');
        $router->get('/category/list', 'Admin\CategoryController@list');
        $router->get('/category/add', 'Admin\CategoryController@add');
        $router->post('/category/add', 'Admin\CategoryController@add');
        $router->get('/category/edit', 'Admin\CategoryController@edit');
        $router->post('/category/edit', 'Admin\CategoryController@edit');
        $router->post('/category/del', 'Admin\CategoryController@del');

        //文章管理
        $router->get('/article', 'Admin\ArticleController@index');
        $router->get('/article/list', 'Admin\ArticleController@list');
        $router->get('/article/add', 'Admin\ArticleController@add');
        $router->post('/article/add', 'Admin\ArticleController@add');
        $router->get('/article/edit', 'Admin\ArticleController@edit');
        $router->post('/article/edit', 'Admin\ArticleController@edit');
        $router->post('/article/del', 'Admin\ArticleController@del');

        //评论管理
        $router->get('/comment', 'Admin\CommentController@index');
        $router->get('/comment/list', 'Admin\CommentController@list');
        $router->get('/comment/reply', 'Admin\CommentController@reply');
        $router->post('/comment/reply', 'Admin\CommentController@reply');
        $router->post('/comment/del', 'Admin\CommentController@del');
    });

});
